package com.lanyun.dao;

import com.lanyun.pojo.Product;
import com.lanyun.pojo.SalesOrder;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Repository
public interface SalesOrderDao {

    List<SalesOrder> getAll();

    int addSalesOrder(SalesOrder salesOrder);

    int addSalesOrderDetail(@Param("oid") String oid,@Param("datas") List<Map<String,String>> datas,@Param("state") String state);

    SalesOrder getById(String id);

    List<Map<String,String>> getDetailsById(String id);

    int delSalesOrderDetail(String oid);

    List<Map<String,String>> getProductsByKeeperAndOrder(@Param("oid") String oid,@Param("keeperId") String keeperId);

    /*更改订单中的商品状态*/
    int changeOrderProductState(@Param("oid") String oid,@Param("pid") String pid,@Param("state") String state);

    /*出库后改变库存*/
    int changeStock(@Param("pid") String pid,@Param("wid") String wid,@Param("amount") Integer amount);

    /*查询某订单某一种状态的商品*/
    int getProductsCountByState(@Param("oid") String oid,@Param("state") String state);

    /*修改订单出库*/
    int outTheOrder(@Param("oid") String oid,@Param("outDate") Date outDate,@Param("keeperId") String keeperId,@Param("state") String state);

    /*添加库存记录*/
    int addStockInfo(@Param("operatorId") String operatorId,
                     @Param("operateDate") Date operateDate,
                     @Param("warehouseId") String warehouseId,
                     @Param("productId") String productId,
                     @Param("amount") String amount,
                     @Param("type") String type);

    /*多条件查询*/
    List<SalesOrder> getByCondition(@Param("customerName") String customerName,
                                    @Param("salesmanName") String salesmanName,
                                    @Param("keeperName") String keeperName,
                                    @Param("enterDateStart") Date enterDateStart,
                                    @Param("enterDateEnd") Date enterDateEnd,
                                    @Param("outDateStart") Date outDateStart,
                                    @Param("outDateEnd") Date outDateEnd,
                                    @Param("state") String state);

    int delById(String oid);

    int delBatch(@Param("ids") String[] ids);

    List<SalesOrder> getByKeeper(String kid);
}
